package com.test.vue.utils;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.test.vue.emuns.ResponseEnum;

import java.io.Serializable;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResultEntity implements Serializable {

    private int code;
    private String message;
    private Object content;

    public ResultEntity() {
    }

    public ResultEntity(int code, String message, Object content) {
        this.code = code;
        this.message = message;
        this.content = content;
    }

    public ResultEntity(ResponseEnum responseEnum, Object content) {
        this.code = responseEnum.getCode();
        this.message = responseEnum.getMsg();
        this.content = content;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getcontent() {
        return content;
    }

    public void setcontent(Object content) {
        this.content = content;
    }

    public static ResultEntity ok(Object content) {
        return new ResultEntity(200, "success", content);
    }

    public static ResultEntity err(Object content) {
        return new ResultEntity(100, "error", content);
    }

    public static ResultEntity findOk(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.SUCCESS_RESPONSE, content);
        return result;
    }

    public static ResultEntity findErr(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.FAIL_SEARCH, content);
        return result;
    }

    public static ResultEntity saveOk(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.SUCCESS_SAVE, content);
        return result;
    }

    public static ResultEntity saveErr(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.FAIL_SAVE, content);
        return result;
    }

    public static ResultEntity delOk(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.SUCCESS_DELETE, content);
        return result;
    }

    public static ResultEntity delErr(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.FAIL_DELETE, content);
        return result;
    }

    public static ResultEntity uploadOk(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.SUCCESS_UPLOAD, content);
        return result;
    }

    public static ResultEntity uploadErr(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.FAIL_UPLOAD, content);
        return result;
    }

    public static ResultEntity uploadEmpty(Object content) {
        ResultEntity result = new ResultEntity(ResponseEnum.FAIL_UPLOAD_EMPTY_FILES, content);
        return result;
    }
}